package net.sunofbeaches.dao;

import net.sunofbeaches.pojo.Article;
import org.mapstruct.Mapping;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

public interface ArticleDao extends JpaRepository<Article,String> , JpaSpecificationExecutor<Article> {
    Article findOneById(String articleId);

    @Modifying
    @Query(nativeQuery = true,value = "update `tb_article` SET `state` = '0' WHERE `id` = ?")
    int deleteArticleByState(String articleId);

    @Modifying
    int deleteAllById(String articleId);

    @Query(nativeQuery = true,value = "SELECT `labels` FROM `tb_article` WHERE `id` = ?")
    String listArticleLabelsById(String articleId);
}
